package org.ghost.spring.cloud.provider.demo.controller;

import org.apache.commons.lang3.RandomUtils;
import org.ghost.spring.cloud.provider.demo.dto.RspDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 * @date 2020-09-02 10:09
 */
@RestController
@RequestMapping(value = "hello")
public class HelloController extends BaseController {
    private final static Logger logger = LoggerFactory.getLogger(HelloController.class);

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public RspDTO get(@PathVariable String id) {
        try {
            Thread.sleep(RandomUtils.nextInt(1, 1500));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        logger.info("*****HelloController.get通过id查询,id={}", id);
        return this.render(id);
    }
}
